<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>for...of</title>
</head>
<body>
  <script>
    /**
     * 1. 可以像for循环一样终止循环
     * 2. entries()方法
    */

    // 1. 可以像for循环一样终止循环
    const arr = ['apple', 'orange', 'peer'];
    for (const item of arr) {
      // if (item === 'orange') break; // apple
      if (item === 'orange') continue; // apple peer
      console.log(item);
    }

    // 2. entries()方法
    for (const [key, value] of arr.entries()) {
      if (key === 1) break;
      console.log('key and value', key, value)
    }
  </script>
</body>
</html>